<template>
  <div class="login-register">
      <div class="TitleBar">
        <div class="TitleText">
          宝钢气流热负荷分类与预测系统
        </div>
      </div>
    <div class="contain">
      <div class="big-box" :class="{active:isPhoneLogin}">
        <div class="big-contain" key="bigContainLogin" v-if="isPhoneLogin">
          <div class="btitle">账户登录</div>
          <div class="bform">
            <div class="bform1">
              <el-input style="width: 70%" type="text" placeholder="账号" v-model="form.account"/>
              <el-input style="width: 70%; margin-top: 5%" type="password" placeholder="密码" v-model="form.password" show-password/>
              <span class="errTips" v-if="passwordError">* 密码填写错误 *</span>
            </div>
            <button class="bbutton" @click="login">登录</button>
          </div>
<!--          <div style="display: flex;flex-direction: row;width: 80%">-->
<!--            <div style="font-size: 14px;margin-right: 50%">-->
<!--              <a href="#/fandpassword">注册新账号</a>-->
<!--            </div>-->
<!--            <div style="font-size: 14px">-->
<!--              <a href="#/fandpassword">忘记密码？点击找回</a>-->
<!--            </div>-->
<!--          </div>-->
        </div>
      </div>
    </div>
  </div>
</template>


<script>
export default {
  name: "Login",
  data() {
    return {
      disabled: false,
      countdown: 0,
      //登录者的id
      loginerId: '',
      clearable: true,
      //为true表示正在登录，用来控制页面显示
      isPhoneLogin: true,
      telError: false,
      passwordError: false,
      existed: false,
      verificationerror: false,
      //验证码倒计时
      num: "",
      form: {
        account: '',
        tel: '',
        password: '',
        code: ''
      },
      confirm_disabled: false,
      loginForm: {
        no: '',
        password: ''
      },

    }
  },
  methods: {
    login() {
      this.confirm_disabled = true;
      console.log(this.form)
      this.$axios.post(this.$httpUrlUser + '/loginByPwd', this.form).then(res => res.data).then(res => {
        console.log(res)
        if (res.code === 200) {
          //存储session
          sessionStorage.clear()
          sessionStorage.setItem("CurUser", JSON.stringify(res.data.name))
          sessionStorage.setItem("UserStatue", res.data.statue)

          // 存储token
          // sessionStorage.setItem('tokenName', res.data.token.tokenName)
          // sessionStorage.setItem('tokenValue', res.data.token.tokenValue)

          //跳转到主页
          this.$router.replace('/Home');
        } else {
          this.confirm_disabled = false;
          this.$message.warning(res.msg);
          return false;
        }
      });
    },
  }
}
</script>

<style scoped>

.hintBarr .hinton {
  font-size: 14px;
  cursor: pointer;
  color: #7EA2C1;
  text-decoration: underline;
  margin-left: 5px;
  margin-right: 5px;
}

.hintBarr .hintoff {
  font-size: 14px;
  cursor: pointer;
  margin-left: 5px;
  margin-right: 5px;
}


.box .button {

  height: 30px;
  display: inline-block;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  background: #f0f0f0;
  border: 0px solid #DCDFE6;
  color: #747474;
  -webkit-appearance: none;
  text-align: center;
  box-sizing: border-box;
  outline: 0;
  margin: 4px;
  transition: .1s;
  font-weight: 500;
  padding: 10px 10px;
  font-size: 13px;
  border-radius: 9px;

}


.TitleText {
  padding-top: 4%;
  text-align: center;
  font-size: 2.7em;
  font-weight: bold;
  color: white;
}

.login-register {
  background-image: url("../assets/background.jpg");
  background-size: 100% 100%;
  margin: 0px;
  width: 100vw;
  height: 100vh;
}

.contain {
  width: 35%;
  height: 55%;
  position: relative;
  top: 45%;
  left: 75%;
  transform: translate(-50%, -50%);
  background-color: #fff;
  border-radius: 30px;
  box-shadow: 0 0 3px #f0f0f0,
  0 0 6px #f0f0f0;
}

.big-box {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 30%;
  transform: translateX(0%);
  transition: all 1s;
}

.big-contain {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  align-content: space-around;
}

.btitle {
  font-size: 1.5em;
  font-weight: bold;
  color: rgb(81, 133, 206);
}

.bform {
  width: 100%;
  height: 50%;
  margin-top: 5px;
  padding: 2em 0;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
}

.bform1 {
  width: 100%;
  height: 40%;
  padding: 2px;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
}

.bform .errTips {
  display: block;
  width: 50%;
  text-align: left;
  color: red;
  font-size: 0.7em;
  margin-left: 1em;
}

.bform .infoTips {
  display: block;
  width: 50%;
  text-align: left;
  color: #888d90;
  font-size: 0.8em;
  margin-left: 1em;
}

.bform input {
  width: 54%;
  height: 30px;
  border: none;
  outline: none;
  border-radius: 10px;
  margin-top: 4px;
  padding-left: 2em;
  background-color: #f0f0f0;
}

.bbutton {
  width: 30%;
  height: 40px;
  border-radius: 24px;
  border: none;
  outline: none;
  background-color: rgb(81, 133, 206);
  color: #fff;
  font-size: 0.9em;
  cursor: pointer;
}

.bbutton:hover {
  box-shadow: 0px 3px 3px 0px rgb(36, 59, 97);
}


.big-box.active {
  left: 0;
  transition: all 0.5s;
}

</style>
